package com.hgyc.mom.mes.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hgyc.mom.common.vo.Result;
import com.hgyc.mom.core.mybatis.QueryWrapperUtil;
import com.hgyc.mom.mes.entity.MesPackageRuleTier;
import com.hgyc.mom.mes.service.MesPackageRuleTierService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 包装层级数量Controller
 *
 * @author fwj
 * @since 2025-06-30
 */
@Tag(name = "包装层级数量控制器", description = "包装层级数量控制器")
@RestController
@RequestMapping("/mes/package/rule/tier")
public class MesPackageRuleTierController {
    @Autowired
    private MesPackageRuleTierService mesPackageRuleTierService;


    @Operation(summary = "查询包装层级数量树列表", description = "查询包装层级数量树列表")
    @PostMapping("/list")
    public Result<List<MesPackageRuleTier>> pageList(@Parameter(description = "查询参数") @RequestBody MesPackageRuleTier mesPackageRuleTier) {
        QueryWrapper<MesPackageRuleTier> wrapper = QueryWrapperUtil.build(mesPackageRuleTier);
        List<MesPackageRuleTier> list = mesPackageRuleTierService.list(wrapper);
        return Result.success(list);
    }

    @Operation(summary = "获取包装层级数量详细信息", description = "获取包装层级数量详细信息")
    @GetMapping(value = "/{id}")
    public Result getInfo(@Parameter(description = "包装层级数量ID") @PathVariable("id") Long id) {
        return Result.success(mesPackageRuleTierService.getById(id));
    }

}